Plotting tilings with bokeh
from IPython import get_ipython
if get_ipython() is not None:
get_ipython().run_line_magic('load_ext', 'autoreload')
get_ipython().run_line_magic('autoreload', '2')
from bokeh.io import output_notebook, show
from bokeh.models import ColumnDataSource, Grid, LinearAxis, Patches, Plot
from tilings import utils as u
from tilings import base as b
import numpy as np
from myst_nb import glue
seed_t = u.get_seed()
def get_cds(t:b.Tiling)-> ColumnDataSource:
coords = [list(p.exterior.coords) for p in t.polys]
xs = [[p[0] for p in c] for c in coords]
ys = [[p[1] for p in c] for c in coords]
return ColumnDataSource({"xs":xs, "ys":ys})
plot = Plot(
title=None, plot_width=300, plot_height=300,
min_border=0, toolbar_location=None)
glyph = Patches(xs="xs", ys="ys", fill_color="#fb9a99", fill_alpha=0.1)
plot.add_glyph(get_cds(seed_t), glyph)
show(plot)
ts = [seed_t]
for i in range(30):
ts = u.update_tilings(ts)
print(i, len(ts))
irreg = u.get_irreg(ts)
if irreg is not None:
print("irreg found")
break
0 1
1 2
2 4
3 4
4 4
5 6
6 9
7 8
8 7
9 10
10 13
11 20
12 26
13 31
14 33
15 20
16 28
17 40
18 56
19 62
20 84
21 86
22 78
23 94
24 92
25 98
26 150
27 168
28 219
29 215
for t in ts:
plot.add_glyph(get_cds(t), glyph)
show(plot)